<?php
class Admin_Model_TableColumn_TinNhan {
	const DATE_FORMAT_FULL_EN = 'Y-m-d H:i:s';
	const DATE_FORMAT_FULL_VN = 'd/m/Y H:i:s';
	const DATE_FORMAT_SHORT_VN = 'd-m-Y';
	protected $id;
	protected $nguoi_nhan;
	protected $nguoi_gui;
	protected $ngay_gui;
	protected $tieu_de;
	protected $noi_dung;
	protected $loai;
	protected $ptr_tin_rao;
	protected $ogh_tin_rao;

	public function __construct(array $options = null) {
		if (is_array($options)) {
			$this->setOptions($options);
		}
	}

	public function __set($name, $value) {
		$method = 'set' . $name;
		if (('mapper' == $name) || !method_exists($this, $method)) {
			throw new Exception('Invalid content property');
		}
		$this->$method($value);
	}

	public function __get($name) {
		$method = 'get' . $name;
		if (('mapper' == $name) || !method_exists($this, $method)) {
			throw new Exception('Invalid content property');
		}
		return $this->$method();
	}

	public function setOptions(array $options) {
		$methods = get_class_methods($this);
		foreach ($options as $key => $value) {
			$method = 'set' . ucfirst($key);
			if (in_array($method, $methods)) {
				$this->$method($value);
			}
		}
		return $this;
	}
	//Id
	public function getId() {
		return $this->id;
	}
	public function setId($value) {
		$this->id = $value;
	}
	//nguoi_nhan
	public function getNguoi_nhan() {
		return $this->nguoi_nhan;
	}
	public function setNguoi_nhan($value) {
		$this->nguoi_nhan = $value;
	}
	//nguoi_gui
	public function getNguoi_gui() {
		return $this->nguoi_gui;
	}
	public function setNguoi_gui($value) {
		$this->nguoi_gui = $value;
	}
	//ngay_gui
	public function getNgay_gui($format = self::DATE_FORMAT_FULL_VN) {
		return $this->ngay_gui;
		return date($format,strtotime($this->ngay_gui));
	}
	public function setNgay_gui($value) {
		$this->ngay_gui = $value;
	}
	//tieu_de
	public function getTieu_de() {
		return $this->tieu_de;
	}
	public function setTieu_de($value) {
		$this->tieu_de = $value;
	}
	//noi_dung
	public function getNoi_dung() {
		return $this->noi_dung;
	}
	public function setNoi_dung($value) {
		$this->noi_dung = $value;
	}
	//loai
	public function getLoai() {
		return $this->loai;
	}
	public function setLoai($value) {
		$this->loai = $value;
	}
	//ptr_tin_rao
	public function getPtr_tin_rao() {
		return $this->ptr_tin_rao;
	}
	public function setPtr_tin_rao($value) {
		$this->ptr_tin_rao = $value;
	}
	//ogh_tin_rao
	public function getOgh_tin_rao() {
		return $this->ogh_tin_rao;
	}
	public function setOgh_tin_rao($value) {
		$this->ogh_tin_rao = $value;
	}
//to array
	public function toArray() {
		$data= array(
			'id'		    =>$this->id,
			'nguoi_nhan'    =>$this->nguoi_nhan,
			'nguoi_gui'     =>$this->nguoi_gui,
			'ngay_gui' 	    =>$this->ngay_gui,
			'tieu_de' 	    =>$this->tieu_de,
			'noi_dung'	    =>$this->noi_dung,
			'loai'		    =>$this->loai,
			'ptr_tin_rao'	=>$this->ptr_tin_rao,
			'ogh_tin_rao'	=>$this->ogh_tin_rao,
			
		);
		$item = array();
		foreach ($data as $key =>$value) {
			if ($value!=''&& $value!=null) {
				$item[$key]=$value;
			}
		}
		return $item;
	}
}